package com.sky.controller.admin;

import com.sky.anno.AutoFill;
import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.result.Result;
import com.sky.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author pm
 * date: 2024/5/17 20:56
 * Description:
 */

@RestController
@Slf4j
@Api(tags = "订单管理功能")
@RequestMapping("/admin/order")
public class OrderController {

    @Autowired
    private OrdersService ordersService;


    /**
     *  取消订单
     * @param ordersCancelDTO
     * @return
     */
    @PutMapping("/cancel")
    @ApiOperation("取消订单")
    public Result cancelOrder(@RequestBody OrdersCancelDTO ordersCancelDTO){

        log.info("取消订单数据:{}",ordersCancelDTO);

        ordersService.cancelOrder(ordersCancelDTO);

        return Result.success();
    }


    /**
     * 派送订单
     * @param id
     * @return
     */
    @PutMapping("/delivery/{id}")
    @ApiOperation("派送订单")
    public Result deliveryOrder(@PathVariable Long id){

        log.info("派送订单数据:{}",id);

        ordersService.deliveryOrder(id);

        return Result.success();
    }



    /**
     * 派送订单
     * @param id
     * @return
     */
    @PutMapping("complete/{id}")
    @ApiOperation("完成订单")
    public Result completeOrder(@PathVariable Long id){

        log.info("完成订单数据:{}",id);

        ordersService.completeOrder(id);

        return Result.success();
    }

}
